package com.jqkb.adapters;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jqkb.R;
import com.jqkb.pages.ForwardDetailActivity;

import java.util.List;

/**
 * Created by alimjantursun on 18/5/29.
 */
public class TargetAdapter extends RecyclerView.Adapter {
    private final List list;
    private final Context context;

    public TargetAdapter(Context context, List list) {
        this.list = list;
        this.context = context;

    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(context).inflate(R.layout.forward_list_item, parent, false);
        return new ClassHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {


        if (holder instanceof ClassHolder) {


            ((ClassHolder) holder).dateTv.setText("2017-10-10 18:10:45");
            ((ClassHolder) holder).titleTv.setText("这是个标题这是个标题这是个标题这是个标题这是个标题这是个标题这是个标题这是个标题");
            ((ClassHolder) holder).senderTv.setText("努尔苏坦");
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context, ForwardDetailActivity.class));
            }
        });

    }

    public class ClassHolder extends RecyclerView.ViewHolder {


        TextView dateTv;
        TextView titleTv;
        TextView senderTv;

        public ClassHolder(View itemView) {
            super(itemView);
            dateTv = (TextView) itemView.findViewById(R.id.dateTv);
            titleTv = (TextView) itemView.findViewById(R.id.titleTv);
            senderTv = (TextView) itemView.findViewById(R.id.senderTv);

        }
    }

    @Override
    public int getItemCount() {
        return 20;
    }
}
